<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>04 Document</title>
    <script src="./js/vue.js"></script>
    <style>
        *{
            padding: 0;
            margin: 0;
        }
        .bottom{
            position: fixed;
            bottom: 0;
            height: 80px;
            line-height: 80px;
            width: 100%;
            display: flex;
        }
        .bottom span{
            display: block;
            flex: 1;
            background-color: blue;
            color: coral;
            text-align: center;
        }
        .bottom .active{
            background-color: darkkhaki;
        }

    </style>
</head>
<body>
    <div id="app">
        <component :is="com">

        </component>

        <p class="bottom">
            <span v-for="item in list" @click="changeIndex(item)" :class="{active : item.id == activeIndex}">
                {{item.msg}}
            </span>
          
        </p>

    </div>

    
    
</body>
<template id="mine">
    <div>
        个人页面
    </div>
</template>

<template id="list">
    <div>

        列表页面
    </div>
</template>

<template id="about">
    <div>

        关于页面
    </div>
</template>

<template id="props">
    <div>
        父传子
        <child :num="n"></child>
           
    </div>
</template>

<template id="child">
    <div>
        我是子组件
        父组件给我传了
        {{num}}


    </div>

</template>
<script>
    let child = {
        template:"#child",
        props:["num"],
    };

    let mine = {
        template:"#mine"
    };
    let list = {
        template:"#list"
    };
    let about = {
        template:"#about"
    };
    let props = {
        template:"#props",
        data(){
            return {
                n:999,
            }
        },
        components:{
            child
        }

    };

    new Vue({
        el:"#app",
        data:{
            com:"mine",
            activeIndex:1,
            list:[{id:1,msg:"个人",com:"mine"},{id:2,msg:"列表",com:"list"},{id:3,msg:"关于",com:"about"},{id:4,msg:"父传子",com:"props"}]

        },
        methods:{
            changeIndex(item){
                this.com = item.com;
                this.activeIndex = item.id;

            }
            
        },
        components:{
            mine,
            list,
            about,
            props,

        }
    })


</script>
</html>